tow=[1, 2, 5, 3, 4, 8, 2]
def shouyi(tow):
    n=len(tow)
    dp=[0]*n
    if n==0:
        return 0
    if n==1:
        return tow[0]
    dp[0]=tow[0]
    dp[1]=max(tow[0],tow[1])
    for i in range(1,n):
        dp[i]=max(dp[i-1],dp[i-2]+tow[i])
    return dp[n-1]
print(shouyi(tow))
